package com.ecplatform.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ecplatform.common.annotation.AutoFill;
import com.ecplatform.common.constant.OperationType;
import com.ecplatform.user.pojo.po.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM user WHERE username = #{username}")
    User getByUsername(String username);

    @AutoFill(OperationType.INSERT)
    @Insert("INSERT INTO user (username, password, nickname, email, phone, created_time, updated_time, status, role) VALUES (#{username}, #{password}, #{nickname}, #{email}, #{phone}, #{createdTime}, #{updatedTime}, #{status}, #{role})")
    void saveUser(User user);
}
